﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.OracleClient;
using System.IO;
using System.Windows;
using ReflectionStudio.Components.UserControls;
using ReflectionStudio.Core;
using ReflectionStudio.Core.Database;
using ReflectionStudio.Core.Events;
using ReflectionStudio.Core.Helpers;
using CADInterface;
namespace WPFExcelReport
{
    /// <summary>
    /// Interaction logic for SETUPABON.xaml
    /// </summary>
    public partial class CADMAPINTEX : DocumentBase
    {
        public DSTCADDB dSTCADDB;
        DataSet setDISPO = new DataSet();
        public OracleConnection OracleDB;
        public OracleCommand orlReadCommand = new OracleCommand();
        public IntexReptServBLClient proxy;
        private Dictionary<string, object> dicParamater;
        public ExcelX.ExcelLib.ExcelAgent exAgent;
        CADMAPINTEXData m_Data;
        public CADMAPINTEX()
        {
            InitializeComponent();
            dSTCADDB = (DSTCADDB)TryFindResource("dSTCADDB");
            this.Name = "参数设定";
            this.Title = "参数设定";
            exAgent = new ExcelX.ExcelLib.ExcelAgent("");
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {

            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
        public override void SetUp(Dictionary<string, object> dicParamater)
        {
            try
            {
                using (new LongOperation(this, "读取符合条件的记录"))
                {
                    base.SetUp(dicParamater);
                    this.dicParamater = dicParamater;
                    OracleDB = (OracleConnection)dicParamater["OracleDB"];
                    proxy = (IntexReptServBLClient)dicParamater["proxy"];
                    m_Data = new CADMAPINTEXData(OracleDB, proxy);
                    dSTCADDB = (DSTCADDB)TryFindResource("dSTCADDB");
                }
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
        private void btnGetCADMap_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                dSTCADDB.Clear();
                dSTCADDB.AcceptChanges();
                DataSet setresult = m_Data.ReSetData();
                dSTCADDB.Merge(setresult);
                dSTCADDB.AcceptChanges();
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
        private void cmdLoadCADMap_Click(object sender, RoutedEventArgs e)
        { 
            DataSet setResult = m_Data.LoadSetCADMAPINTEX();
            dSTCADDB.Merge(setResult); 
            
        }
    }
}
